# -*- coding: utf-8 -*-
# @Time     : 2021/11/26 11:05
# @Author   : Aries
# @File     : 多层装饰器.py
# @Describe : 
# @Software : PyCharm

def permissions(func):
    '''权限验证器'''
    print("权限验证装饰器...")
    def inner(*args, **kwargs):
        username, _ = args
        if username == "admin":
            print("权限验证成功...")
            return func(*args, **kwargs)
        else:
            raise ValueError(f"{username}该用户不具备权限")
    return inner

def identity(func):
    '''身份验证器'''
    print("身份验证装饰器...")
    def inner(*args, **kwargs):
        username, pwd = args
        if username in ("admin", "jess", "lucy") and pwd == "123":
            print("identity success...")
            return func(*args, **kwargs)
        raise ValueError("用户名密码错误，身份验证失败...")
    return inner

@identity
@permissions
def user(username, pwd):
    print(username, pwd)
    return "login success"

if __name__ == '__main__':
    print(user("admin", "123"))
    #print(user("jess", "123"))
